using System;
using System.Windows.Forms;

using FreeFlow.Administration;

namespace FreeFlowAdministrator
{
	/// <summary>
	/// Summary description for TableAdaptor.
	/// </summary>
	public class TableAdaptor : Adaptor, IRefreshable
	{
    private Table table;
		public TableAdaptor(Table table)
		{
			this.table = table;
		}

    public override string Text
    {
      get
      {
        return table.Name;
      }
    }

    public override object Object
    {
      get
      {
        return table;
      }
    }

    public override int ImageIndex
    {
      get
      {
        return 33;
      }
    }

    #region IRefreshable Members

    public void Refresh()
    {
      table.Refresh();
    }

    #endregion

    public override void AddChildren(TreeNode node)
    {
      TreeNode childNode = TreeNodeFactory.CreateTreeNode(new ColumnsAdaptor(table.Columns));
      node.Nodes.Add(childNode);

      childNode = TreeNodeFactory.CreateTreeNode(new TableDataAdaptor(table));
      node.Nodes.Add(childNode);
    }
  }
}
